package com.manager.service.impl;

import com.manager.bean.QRcodeExample;
import com.manager.bean.QRcodeKey;
import com.manager.mapper.QRcodeMapper;
import com.manager.service.QRcodeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("qrcodeService")
public class QRcodeServiceImpl implements QRcodeService {
    @Resource
    private QRcodeMapper QRcodeDao;

    @Override
    public QRcodeKey queryById(Integer id) {
        QRcodeExample qRcodeExample = new QRcodeExample();
        QRcodeExample.Criteria criteria = qRcodeExample.createCriteria();
        criteria.andStuIdEqualTo(id);
        List<QRcodeKey> qRcodeKeys = QRcodeDao.selectByExample(qRcodeExample);
        if (qRcodeKeys.size()==0)
            return null;
        else
            return qRcodeKeys.get(0);
    }


    @Override
    public int insert(QRcodeKey QRcode) {
        return QRcodeDao.insert(QRcode);
    }


    @Override
    public int deleteById(Integer id) {
        QRcodeExample qRcodeExample = new QRcodeExample();
        QRcodeExample.Criteria criteria = qRcodeExample.createCriteria();
        criteria.andStuIdEqualTo(id);
        return QRcodeDao.deleteByExample(qRcodeExample);
    }
}
